package com.voc.im.bean;


import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import java.io.File;

public class Account<T> {

    private T data;

    public Account(T data) {
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static class Login {
        private StringProperty username;
        private StringProperty password;

        public Login(String username, String password) {
            this.setUsername(username);
            this.setPassword(password);
        }

        public String getUsername() {
            return usernameProperty().get();
        }

        public StringProperty usernameProperty() {
            if (username == null) {
                username = new SimpleStringProperty();
            }
            return username;
        }

        public void setUsername(String username) {
            this.usernameProperty().set(username);
        }

        public String getPassword() {
            return passwordProperty().get();
        }

        public StringProperty passwordProperty() {
            if (password == null) {
                password = new SimpleStringProperty();
            }
            return password;
        }

        public void setPassword(String password) {
            this.passwordProperty().set(password);
        }
    }

    public static class Register {
        private StringProperty nickname;
        private StringProperty password;
        private StringProperty inviter;

        public Register(String nickname, String password, String inviter) {
            this.setNickname(nickname);
            this.setPassword(password);
            this.setInviter(inviter);
        }

        public String getNickname() {
            return nicknameProperty().get();
        }

        public StringProperty nicknameProperty() {
            if (nickname == null) {
                nickname = new SimpleStringProperty();
            }
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nicknameProperty().set(nickname);
        }

        public String getPassword() {
            return passwordProperty().get();
        }

        public StringProperty passwordProperty() {
            if (password == null) {
                password = new SimpleStringProperty();
            }
            return password;
        }

        public void setPassword(String password) {
            this.passwordProperty().set(password);
        }

        public String getInviter() {
            return inviterProperty().get();
        }

        public StringProperty inviterProperty() {
            if (inviter == null) {
                inviter = new SimpleStringProperty();
            }
            return inviter;
        }

        public void setInviter(String inviter) {
            this.inviterProperty().set(inviter);
        }
    }

    public static class VCard {
        private StringProperty username;
        private StringProperty nickname;
        private StringProperty sex;
        private StringProperty region;
        private StringProperty autograph;
        private ObjectProperty<File> heard;


        public String getNickname() {
            return nicknameProperty().get();
        }

        public StringProperty nicknameProperty() {
            if (nickname == null) {
                nickname = new SimpleStringProperty();
            }
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nicknameProperty().set(nickname);
        }

        public String getUsername() {
            return usernameProperty().get();
        }

        public StringProperty usernameProperty() {
            if (username == null) {
                username = new SimpleStringProperty();
            }
            return username;
        }

        public void setUsername(String username) {
            this.usernameProperty().set(username);
        }

        public String getSex() {
            return sexProperty().get();
        }

        public StringProperty sexProperty() {
            if (sex == null) {
                sex = new SimpleStringProperty();
            }
            return sex;
        }

        public void setSex(String sex) {
            this.sexProperty().set(sex);
        }

        public String getRegion() {
            return regionProperty().get();
        }

        public StringProperty regionProperty() {
            if (region == null) {
                region = new SimpleStringProperty();
            }
            return region;
        }

        public void setRegion(String region) {
            this.regionProperty().set(region);
        }

        public String getAutograph() {
            return autographProperty().get();
        }

        public StringProperty autographProperty() {
            if (autograph == null) {
                autograph = new SimpleStringProperty();
            }
            return autograph;
        }

        public void setAutograph(String autograph) {
            this.autographProperty().set(autograph);
        }

        public File getHeard() {
            return heardProperty().get();
        }

        public ObjectProperty<File> heardProperty() {
            if (heard == null) {
                heard = new SimpleObjectProperty<>();
            }
            return heard;
        }

        public void setHeard(File heard) {
            this.heardProperty().set(heard);
        }
    }
}
